package com.kingdee.eas.wzgzw.base.app;

import org.apache.log4j.Logger;
import javax.ejb.*;
import java.rmi.RemoteException;
import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK;
//import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean;
//import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import java.lang.String;

import com.kingdee.eas.basedata.assistant.AssistantCtrlUnitUtils;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.wzgzw.base.OperatingInfo;
import com.kingdee.eas.framework.ObjectBaseCollection;
import com.kingdee.eas.framework.app.DataBaseControllerBean;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.wzgzw.base.OperatingCollection;
import com.kingdee.eas.framework.DataBaseCollection;

public class OperatingControllerBean extends AbstractOperatingControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.wzgzw.base.app.OperatingControllerBean");
	    protected void addnewCheck(Context ctx, IObjectValue model)
	    throws BOSException, EASBizException
	  {
	    ((OperatingInfo)model).setCU(AssistantCtrlUnitUtils.getRootCU(ctx));
	    _checkNumberBlank(ctx, model);
	    _checkNameBlank(ctx, model);
	   _checkNameDup(ctx, model);
	    _checkNumberDup(ctx, model);
	  }
	
	  protected IObjectPK _addnew(Context ctx, IObjectValue model)
	    throws BOSException, EASBizException
	  {
	    addnewCheck(ctx, model);
	    return super._addnew(ctx, model);
	  }
	
	  protected void _addnew(Context ctx, IObjectPK pk, IObjectValue model)
	    throws BOSException, EASBizException
	  {
	    addnewCheck(ctx, model);
	    super._addnew(ctx, pk, model);
	  }
	
	  protected void updateCheck(Context ctx, IObjectPK pk, IObjectValue model)
	    throws BOSException, EASBizException
	  {
	    _checkNumberBlank(ctx, model);
	    _checkNameBlank(ctx, model);
	    OperatingInfo oldModel = getOperatingInfo(ctx, pk);
	    if (!((OperatingInfo)model).getNumber().equals(oldModel.getNumber()))
	    {
	      _checkNumberDup(ctx, model);
	    }
	
	    if (!((OperatingInfo)model).getName().equals(oldModel.getName()))
	    {
	      _checkNameDup(ctx, model);
	    }
	  }
	
	  protected void _update(Context ctx, IObjectPK pk, IObjectValue model)
	    throws BOSException, EASBizException
	  {
	    updateCheck(ctx, pk, model);
	    super._update(ctx, pk, model);
	  }
}